<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:fn="http://java.sun.com/jsp/jstl/functions"
	xmlns:p="http://primefaces.org/ui"
	xmlns:cc="http://java.sun.com/jsf/composite"
	xmlns:hmrList="http://java.sun.com/jsf/composite/list"	>

<cc:interface>
	<cc:attribute name="handler"		type="com.hemerasolutions.v2trainer.component.interfaces.table.EquipmentDetailsCompInterface" required="true"/>
	<cc:attribute name="editable"		type="java.lang.Boolean" default="false" required="true"/>
</cc:interface>

<cc:implementation>
	<span id="#{cc.clientId}" >
		<h:panelGrid  columns="2" columnClasses="top-align,top-align" rendered="#{cc.attrs.handler.equipment != null}" > 
			<h:column>
				<div  style="display:block;height:90%;">
					<h:form prependId="false">		
						<h:panelGrid columns="2" style="width:400px;" > 
				            <h:outputText value="#{msgs.Name} :" />
				            <p:inputText id="equipmentName"     value="#{cc.attrs.handler.equipment.name}" maxlength ="20" size="20" disabled="#{cc.attrs.editable}"  />
			
							<h:outputText value="#{msgs.Description} :"  />
							<p:inputTextarea id="equipmentDescription" rows="4" cols="50"  
								maxlength="180" disabled="#{cc.attrs.editable}"
								autoResize="false"
								value="#{ cc.attrs.handler.equipment.description}" />

							<h:outputText value="#{msgs.Obs} :"  />
							<p:inputTextarea id="equipmentObs" rows="4" cols="50"
								maxlength="180" disabled="#{cc.attrs.editable}"
								autoResize="false"
								value="#{ cc.attrs.handler.equipment.obs}" />
		
		
				            <h:outputText value="#{msgs.Status} :" />
				            <p:selectOneRadio value="#{cc.attrs.handler.equipment.active}" disabled="#{cc.attrs.editable}"  >
				                <f:selectItem itemLabel="#{msgs.Active}"  	itemValue="true"   />
				                <f:selectItem itemLabel="#{msgs.Inactive}"	itemValue="false" />
				            </p:selectOneRadio>
		
							<h:outputLabel 	value="#{msgs.CreatedAt} :"		for="equipmentCreatedAt" rendered="#{cc.attrs.handler.equipment.id != null}"  />
							<p:inputText  	id="equipmentCreatedAt" 	value="#{cc.attrs.handler.equipment.createdAt}" disabled="true" rendered="#{cc.attrs.handler.equipment.id != null}"  >
								<f:convertDateTime locale="pt" dateStyle="long" pattern="dd/MM/yyyy HH:mm" />
							</p:inputText>
			
							<h:outputLabel 	value="#{msgs.ChangedAt} :"		for="equipmentChangedAt" rendered="#{cc.attrs.handler.equipment.id != null}" />
							<p:inputText  	id="equipmentChangedAt" 	value="#{cc.attrs.handler.equipment.lastChange}" disabled="true" rendered="#{cc.attrs.handler.equipment.id != null}" >
								<f:convertDateTime locale="pt" dateStyle="long" pattern="dd/MM/yyyy HH:mm" />
							</p:inputText>
			
							<h:outputLabel 	value="#{msgs.ChangedBy} :"		for="equipmentChangedBy" rendered="#{cc.attrs.handler.equipment.id != null}" />
							<p:inputText  	id="equipmentChangedBy" 	value="#{cc.attrs.handler.equipment.changedBy.email}" disabled="true" rendered="#{cc.attrs.handler.equipment.id != null}" />
							
							<h:outputLabel 	value="#{msgs.Library} :"		for="equipmentLibrary" />
							<p:selectOneMenu id="equipmentLibrary" value="#{cc.attrs.handler.equipment.library}"	  disabled="#{cc.attrs.handler.equipment.id != null}" converter="#{libraryConverter}">
				            	<f:selectItems value="#{cc.attrs.handler.activeUser.librarys}" var="library" itemLabel="#{library.name}" itemValue="#{library}" />
							</p:selectOneMenu>
						</h:panelGrid>
					</h:form>
				</div>
			</h:column>
			<h:column>
				<p:accordionPanel   style="margin-left:20px;min-width:600px;max-width:650px">
					<p:tab title="#{msgs.EquipmentPhotos}"  >
						<hmrList:photosList photosHandler="#{cc.attrs.handler.photosListHandler}" editable="#{cc.attrs.editable}"  />
					</p:tab>
					<p:tab title="#{msgs.EquipmentVideos}" >
						<hmrList:videosList videosHandler="#{cc.attrs.handler.videosListHandler}" editable="#{cc.attrs.editable}" />
					</p:tab>
				</p:accordionPanel>  
			</h:column>
		</h:panelGrid>		
	</span>
</cc:implementation>
</html>	